<?php
namespace Member\Controller;
use Think\Controller;
class MemberController extends CommonController {

    /**
     * 用户登录
     *
     * @return void
     * @author
     **/
    function login()
    {

        if (IS_POST) {

            // print_r(I('post.'));die;
            // 查询单条数据，用find！！！
            $member=$this->Model->where(I('post.'))->find();

            if ($member) {
               session('member',$member);
               redirect(U('index/index'));die;
            }else{
                $this->error('账号或密码错误','',2);die;
            }
        }
        $this->display();
    }

    /**
     * 注册
     *
     * @return void
     * @author
     **/
    function register()
    {
        if (IS_POST) {
             // print_r(I('post.'));die;
            unset($_POST['cPass']);
            // echo $this->Model->getLastSql();die;
            $id=$this->Model->add(I('post.'));

            if ($id>0) {
               $this->success('注册成功,正在跳转。。',U('member/login'),3);die;
            }else{
                $this->error('注册失败','',3);die;
            }
        }
        $this->display();
    }
}